package com.company.backendproject.service;

import com.company.backendproject.dao.BookMapper;
import com.company.backendproject.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : Real
 * @date : 2022/1/13 15:10
 * @description : 书籍的 Service 层
 */
@Service
public class BookService {

    @Autowired
    private BookMapper bookMapper;

    public List<Book> findAllBook() {
        return bookMapper.selectAllBook();
    }

    public Book findBookById(int id) {
        return bookMapper.selectBookById(id);
    }

    public List<Book> findBookPage(int pageNumber, int size) {
        return bookMapper.selectBookPage(pageNumber, size);
    }

    public int saveBook(Book book) {
        return bookMapper.insertBook(book);
    }

    public int updateBook(Book book) {
        return bookMapper.updateBook(book);
    }

    public int deleteBookById(int id) {
        return bookMapper.deleteBookById(id);
    }

}
